<?php
namespace app\common\model;
class Lunbo extends Common {
	protected $insert = ['type' => 1, 'addtime' => SYS_TIME, 'status' => 1];

	protected function getAlldataAttr($value, $data) {
		$data['type'] = config('LUNBO')[$data['type']];
		$data['addtime'] = date('Y-m-d H:i:s', $data['addtime']);
		return $data;
	}

	protected function getAddtimeAttr($value, $data) {
		return date('Y-m-d H:i', $data['addtime']);
	}
	protected function getStarttimeAttr($value) {
		return $value ? strtotime($value) : 0;
	}

	protected function getTypeAttr($value, $data) {
		$type = config("LUNBO");
		return $type[$data['type']];
	}
	protected function getStatusTypeAttr($value, $data) {
		$status = [1 => '开启', 99 => '关闭'];
		return $status[$data['status']];
	}
	protected function getThumbAttr($value) {
		if (strpos($value, "http://") !== false) {
			return $value;
		} else {
			return $value ? $value : '';
		}
	}
	protected function getVideoAttr($value) {
		return 'http://qym.test.coco3g.com/' . $value;
	}
	protected function getLinkurlAttr($value, $data) {
		if ($value) {
			return $value;
		}
		if (strpos($data['thumb'], "http://") !== false) {
			return $data['thumb'];
		} else {
			return $data['thumb'] ? rtrim(APP_URL, "/") . '/' . $data['thumb'] : '';
		}
	}
}